package com.wuzao.streamTest;

import lombok.Data;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *
 * </p>
 *
 * @author wuzuhao
 * @since 2023-08-22
 */
public class CopyListTest {

    class Source {
        private int id;
        private String name;
        private int age;

        public Source(int id, String name, int age) {
            this.id = id;
            this.name = name;
            this.age = age;
        }

        public int getId() {
            return id;
        }

        public String getName() {
            return name;
        }

        public int getAge() {
            return age;
        }
    }

    class Target {
        private int id;
        private String name;

        public Target(int id, String name) {
            this.id = id;
            this.name = name;
        }

        @Override
        public String toString() {
            return "Target{id=" + id + ", name='" + name + '\'' + '}';
        }
    }

    @Test
    public void test() {
//        Source[] sourceArray = {
//                new Source(1, "Alice", 30),
//                new Source(2, "Bob", 25),
//                new Source(3, "Charlie", 35)
//        };
//        Source[] sourceArray = new Source[]{};
//
//        List<Target> targetList = Arrays.stream(sourceArray)
//                .map(source -> new Target(source.getId(), source.getName()))
//                .collect(Collectors.toList());
        String a = "abbc";
        System.out.println(a.lastIndexOf("b"));;

//        System.out.println("++++++++++");
//
//        List<Source> sourceArray2 = new ArrayList<>();
//
//        List<Target> targetList2 = sourceArray2.stream()
//                .map(i -> new Target(i.getId(), i.getName()))
//                .collect(Collectors.toList());
//        targetList2.forEach(System.out::println);
    }
}
